home *** CD-ROM | disk | FTP | other *** search
/ Best of Shareware / Best of PC Windows Shareware 1.0 - Wayzata Technology (7111) (1993).iso / mac / DOS / PROGRAMG / QBTINY12 / QBTINY.DOC < prev    next >
Text File  |  1992-11-19  |  18KB  |  480 lines

  1.                       The QBTiny Library                 page 1
  2.                     =--------------------=
  3.                           Version 1.2
  4.  
  5.        QBTiny  Copyright (c) 1992  Thomas G. Hanlin III
  6.  
  7.  
  8.  
  9. The QBTiny library replaces the default runtime library for
  10. QuickBasic 4.x and PDS 7.x compilers. Using it can reduce the
  11. size of your compiled programs to 20% of their original size.
  12.  
  13. QBTiny does not support floating point math, event trapping, or
  14. several other BASIC features.  The differences between QBTiny
  15. and the default support library are discussed in this manual.
  16.  
  17. The QBTiny collection is copyrighted and may be distributed
  18. only according to the following rule:
  19.  
  20.    All QBTiny files must be distributed together as a unit in
  21.    unmodified form.  No files may be left out or added.
  22.  
  23. You use QBTiny at your own risk.  It has been tested by me on
  24. my own computers, but I will not assume any responsibility for
  25. any problems it may cause you.  QBTiny is a complex library.
  26. IT QUITE PROBABLY HAS SOME BUGS.  If you need a stable library
  27. that has undergone real-life testing by thousands of people,
  28. buy Crescent's P.D.Q.  See PDQINFO.TXT for details.
  29.  
  30. The QBTiny library may be used as-is.  It can no longer be
  31. registered.  If you find the capabilities of QBTiny useful, you
  32. are sure to be pleased with Crescent Software's P.D.Q., which
  33. is a similar but more powerful product.  Besides making your
  34. programs smaller, P.D.Q. lets you make TSRs and provides other
  35. new capabilities for Microsoft BASIC compilers.
  36.  
  37. This manual always refers to the default support library as
  38. BCOM45.LIB, which is for QuickBasic 4.5.  If you are using a
  39. different compiler, you will have a different support library:
  40.   BCOM40.LIB    QuickBasic 4.0 (early release)
  41.   BCOM41.LIB    QuickBasic 4.0 (later release)
  42.   BCL70ENR.LIB  PDS 7.0 (normal default)
  43.   BCL71ENR.LIB  PDS 7.1 (normal default)
  44. Substitute the appropriate library for BCOM45.LIB.  Likewise,
  45. when I say QuickBasic, I am also referring to PDS.  If you need
  46. support for Visual Basic for DOS, once again, Crescent's P.D.Q.
  47. is the best solution.  QBTiny doesn't support VB-DOS.
  48.  
  49.                        Table of Contents                 page 2
  50.  
  51.  
  52.  
  53.  Overview and Legal Info ................................... 1
  54.  
  55.  What Is QBTiny? ........................................... 3
  56.  
  57.  How to Use QBTiny ......................................... 4
  58.  
  59.  Compatibility Issues ...................................... 5
  60.  
  61.  Statements Not Supported .................................. 9
  62.  
  63.  Crescent's P.D.Q. ........................................ 10
  64.  
  65.  Which Runtime? ........................................... 11
  66.  
  67.                        What Is QBTiny?                   page 3
  68.  
  69.  
  70.  
  71. Microsoft's QuickBasic compiler turns your BASIC source code
  72. into an executable (.EXE) file.  It does this by converting the
  73. source code into assembly language.  The simplest statements,
  74. like A% = A% + 1, are converted directly to assembly language.
  75. It would be inefficient to convert more complex statements
  76. directly to assembly language, though, since it would cause a
  77. lot of duplicated code.  Instead of entering complex statements
  78. directly into assembly language, the compiler generates a call
  79. to a standard library routine which takes care of the work.
  80. Most BASIC commands have their own library routines.  For
  81. example, the ASC function causes a call to a library routine
  82. named B$FASC (an abbreviation for Basic Function ASC).  When
  83. you compile a QuickBasic program to a stand-alone .EXE, it
  84. normally uses the BCOM45.LIB library to supply the proper
  85. support code.  The QBTINY.LIB library replaces this.
  86.  
  87. The first question that might pop into your mind is, why bother
  88. with replacing the default library to begin with?  It's free
  89. with the compiler and seems to work just fine as-is!
  90.  
  91. Well, the problem with the default library is that it was
  92. developed over a period of many years by many people.  As you
  93. might expect, this is not a particularly efficient way to make
  94. a library-- there are routines in BCOM45.LIB which are never
  95. even called any more!  The modularity of the routines is also
  96. not at its best.  Now, QBTiny does not support all of the
  97. routines that the default library does, but it was designed
  98. over a period of months by a single expert assembly language
  99. programmer.  This is why the simple program:
  100.  
  101.    PRINT "Hello, world!"
  102.  
  103. comes out to 12,308 bytes when linked with BCOM45, but only
  104. 2,658 bytes when linked with QBTiny.  Yep, the QBTiny version
  105. is a mere 22% of the size of the BCOM45 version!  The more
  106. complex MWORD demo (linked with my BasWiz and PBClone libraries
  107. as well as QBTiny) comes out to 8,700 bytes with QBTiny, as
  108. compared to 34,662 bytes when linked with BCOM45.  You won't
  109. always get savings of this magnitude, but for most small to
  110. medium programs the size difference is quite dramatic.
  111.  
  112. With a few exceptions that will be noted later on, you will not
  113. take any performance penalties for using QBTiny instead of
  114. BCOM45, either.  In fact, many QBTiny routines are faster than
  115. the equivalent routines in the default support library.
  116.  
  117. QBTiny does not support all of the routines that the default
  118. library does. In a few cases, it supports a routine, but not in
  119. quite the same way.  These differences are discussed later.
  120.  
  121.                       How to Use QBTiny                  page 4
  122.  
  123.  
  124.  
  125. Before using QBTiny, you must compile your program from the
  126. command line.  The /o switch is required to tell the compiler
  127. to create an .OBJ that can become a stand-alone EXE file.  Few
  128. of the other switches are compatible with QBTiny.  Compilation
  129. goes like this:
  130.  
  131.    BC program/o;
  132.  
  133. That's the standard way of compiling from the command line--
  134. nothing new there.  The differences come in at LINK time.
  135. Instead of your old LINK syntax, which may have looked a bit
  136. like this:
  137.  
  138.    LINK program/EX;
  139.  
  140. you would use a special syntax, like so:
  141.  
  142.    LINK program/NOD/EX,,NUL,QBTINY;
  143.  
  144. Note that the /EX (sometimes abbreviated /E, which isn't quite
  145. safe) usually makes QuickBasic programs smaller.  LINK isn't
  146. too bright, though, and will apply /EX whether or not it really
  147. shrinks the program.  In the case of QBTiny, you'll sometimes
  148. get better results by leaving the /EX off-- try it both ways to
  149. be sure.  Most programs do benefit from the /EX switch.
  150.  
  151. If LINK reports "unresolved externals" errors, you are using
  152. capabilities which QBTiny doesn't provide.  LINK will tell you
  153. what routine names are missing.  Use SYMDEX to find out what
  154. BASIC statement uses these routines.  If you're not sure where
  155. in your program this BASIC statement is, try creating a pseudo
  156. ASM listing-- BC.EXE will show you the code it generates in
  157. assembly language form, more or less, if you ask politely:
  158.  
  159.    BC program/O/A,program,program;
  160.  
  161. This creates a program.LST file which will help you track down
  162. where the problem lies.
  163.  
  164.                       Compatibility Issues               page 5
  165.  
  166.  
  167.  
  168. The QBTiny library is designed to mimic the default support
  169. library as closely as possible.  However, it is still a work in
  170. progress, and differences remain.  There are slight differences
  171. in the handling of some individual routines and certain types
  172. of routines are not yet supported at all.
  173.  
  174. QBTiny does not support floating point math.  It does not allow
  175. single-precision or double-precision numbers or any routines
  176. which require them.  It does not support event trapping-- no ON
  177. COM, ON ERROR, ON KEY, ON PEN, ON STICK, ON STRIG, or ON
  178. UEVENT.  It does not support dynamic arrays, READ/DATA, RANDOM
  179. file mode, INPUT, or many graphics statements.
  180.  
  181. It will be wise to debug your programs with the default support
  182. library before using QBTiny.  In the interest of efficiency,
  183. QBTiny does little error checking on items that are assumed to
  184. be within the control of the programmer.  For instance, QBTiny
  185. will not know if you use an invalid display page with SCREEN.
  186. However, it will report an error if there is a problem with
  187. OPEN or PRINT#, for example.
  188.  
  189. Still with me?  That may have seemed like a lot, I know.  To
  190. some extent, the reason Microsoft BASIC programs are so large
  191. is because they try to do everything at once.  QBTiny provides
  192. somewhat less capability as a trade-off for smaller files.
  193. There are also new capabilities provided by QBTiny which
  194. provide alternatives to the missing routines which are actually
  195. more convenient than the originals.  For instance, although ON
  196. ERROR isn't allowed, the ERR variable is still updated as you'd
  197. expect.  You don't need slow and bulky error trapping to check
  198. for errors with QBTiny!
  199.  
  200. You can also use the QBTiny library along with other libraries,
  201. which can more than make up for any missing routines.  So you
  202. can't use RANDOMIZE and RND?  No problem!  The RAND function in
  203. my PBClone library is faster, smaller, and easier to use.
  204.  
  205. No need to search through your existing programs to figure out
  206. whether they'll work with QBTiny as-is.  When you link them
  207. with QBTiny, LINK itself will tell you which routines it was
  208. expecting that are not provided by QBTiny.  The SYMDEX utility
  209. (included) translates routine names to the names of the BASIC
  210. statements to which they refer.  BASDEX converts the other way.
  211. Between the two, you will be able to cross-reference BASIC
  212. statements with their symbols. We'll get into more details on
  213. that presently.  Right now, let's take a look at any individual
  214. differences between QBTiny and the default support library.
  215.  
  216.                       Compatibility Issues               page 6
  217.  
  218.  
  219.  
  220. Graphics
  221.  
  222. The QBTiny graphics handler is unlike BCOM45 in a number of
  223. respects.  It does not provide a simulated cursor, allow
  224. graphics paging, or set a default palette on entering a mode.
  225.  
  226.  
  227.  
  228. Keyboard
  229.  
  230. If input is not redirected, keyboard handling is done through
  231. BIOS calls.  The keyboard handler relies on 0000:0496h bit 4 to
  232. tell it whether an enhanced keyboard driver is available.  This
  233. may be incorrectly set on some old PC clones, making keyboard
  234. input unavailable.  If you have this problem, please get in
  235. touch, and I'll try to find a work-around for your machine.
  236. This problem brought to you courtesy of Microsoft, which did
  237. not see fit to provide DOS with enhanced keyboard support,
  238. giving me no alternative but to go with direct machine access.
  239.  
  240.  
  241.  
  242. KILL
  243.  
  244. The QBTiny version of KILL does not support wildcards.
  245.  
  246.  
  247.  
  248. LINE
  249.  
  250. The QBTiny version of LINE does not support patterns in quite
  251. the same way as QuickBASIC.  QuickBASIC always draws lines from
  252. left to right, but does up and down according to the order of
  253. the coordinates you give it.  QBTiny draws the line exactly
  254. according to the order of the coordinates you give it.  In
  255. addition, QuickBASIC uses a somewhat peculiar procedure for
  256. handling patterns when drawing box frames, and ignores patterns
  257. when drawing filled boxes.  QBTiny handles patterns for box
  258. frames more the way you'd expect and supports patterns for
  259. filled boxes.
  260.  
  261.  
  262.  
  263. LONG math
  264.  
  265. The QBTiny library does not support division or MOD for LONG
  266. integers.  I couldn't think of a reasonably efficient way of
  267. implementing 32-bit division on 16-bit processors.
  268.  
  269.                       Compatibility Issues               page 7
  270.  
  271.  
  272.  
  273. OPEN
  274.  
  275. The QBTiny version of OPEN does not support the RANDOM file
  276. mode.  It does not support BASIC devices (COMn:, CONS:, KYBD:,
  277. LPTn:, SCRN:).  However, DOS devices (AUX, COMn, CON, LPTn,
  278. PRN) are supported.  Note that INPUT# and LINE INPUT# are not
  279. available, so the INPUT file mode is rather limited.
  280.  
  281.  
  282.  
  283. PALETTE
  284.  
  285. The QBTiny version of PALETTE does not support the version of
  286. PALETTE without parameters.
  287.  
  288.  
  289.  
  290. SETMEM
  291.  
  292. Since QBTiny only uses as much memory as it needs, unlike
  293. BCOM45 (which allocates all base memory), the SETMEM function
  294. has no real purpose in QBTiny.  Thus, the parameter passed to
  295. SETMEM is meaningless and is ignored.
  296.  
  297.  
  298.  
  299. SWAP
  300.  
  301. The QBTiny version of SWAP does not allow you to swap normal
  302. strings with other data types (such as fixed-length strings or
  303. TYPEd variables).
  304.  
  305.  
  306.  
  307. TIMER
  308.  
  309. The BASIC function TIMER is designed to use floating point,
  310. then convert the result to the appropriate numeric type.  The
  311. QBTiny version has been modified to skip the floating point
  312. handling, and only supports TIMER for long integers.
  313.  
  314. To make sure TIMER returns a long integer, you should enclose
  315. it in CLNG unless it is returning the result directly to a
  316. variable.  For example, these are ok:
  317.  
  318.    A& = TIMER
  319.    PRINT CLNG(TIMER)
  320.  
  321. But not this, since the type isn't apparent (and is assumed to
  322. be floating point):
  323.  
  324.    PRINT TIMER
  325.  
  326.                       Compatibility Issues               page 8
  327.  
  328.  
  329.  
  330. WIDTH
  331.  
  332. The QBTiny version of WIDTH supports 40 and 80 column modes. It
  333. ignores attempts to change the number of rows, however.  While
  334. it does support changing the width of open files, it does not
  335. allow you to change the width of BASIC devices (QBTiny supports
  336. only DOS devices, not BASIC devices).
  337.  
  338.  
  339.  
  340. VAL
  341.  
  342. The BASIC function VAL is designed to use floating point, then
  343. convert the result to the appropriate numeric type.  The QBTiny
  344. version has been modified to skip the floating point handling,
  345. and only supports VAL for integers and longs.  One side effect
  346. is that the QBTiny version won't always detect VAL overflows.
  347.  
  348. To make sure VAL returns an integer or long integer, you should
  349. enclose it in CINT or CLNG unless it is returning the result
  350. directly to a variable.  For example, these are ok:
  351.  
  352.    A% = VAL(St$)
  353.    A% = CINT(VAL(St$)
  354.    PRINT CINT(VAL(St$))
  355.  
  356. But not this, since the type isn't apparent (and is assumed to
  357. be floating point):
  358.  
  359.    PRINT VAL(St$)
  360.  
  361. The QBTiny version of VAL does not mimic certain BASIC bugs
  362. which appear with hex and octal numbers.  It won't gratuitously
  363. sign-extend long integer hex and octal, either.  For example:
  364.  
  365.    Function              QBTiny Result     BASIC Result
  366.    -------------        ---------------   -------------------
  367.    VAL("&H")                   0                 203
  368.    VAL("-&1")                  0          Type Mismatch Error
  369.    CLNG(VAL("&HFFFF"))       65535                -1
  370.  
  371.                    Statements Not Supported              page 9
  372.  
  373.  
  374.  
  375. Floating point:
  376.  
  377.  ATN       CDBL      COS       CSNG      CVD       CVDMBF
  378.  EXP       INT       FIX       LOG       MKD$      MKDMBF$
  379.  MKS$      MKSMBF$   RANDOMIZE RND       SIN       SOUND
  380.  SQR       TAN
  381.  
  382.  
  383.  
  384. Graphics:
  385.  
  386.  CIRCLE    GET       PAINT     PMAP      PUT       VIEW
  387.  WINDOW
  388.  
  389.  
  390.  
  391. Event trapping:
  392.  
  393.  COM       KEY       PEN       PLAY      STRIG     TIMER
  394.  UEVENT
  395.  
  396.  ON ERROR GOTO
  397.  
  398.  
  399.  
  400. Miscellaneous:
  401.  
  402.  CHAIN     CLEAR     DATA      DRAW      ENVIRON   ERASE
  403.  ERDEV     ERDEV$    ERL       FIELD     FILES     INPUT
  404.  INPUT#    IOCTL     IOCTL$    KEY ON    LINE INPUT#
  405.  LOCK      LPRINT USING        PLAY      PRINT USING
  406.  PRINT# USING        READ      REDIM     RESTORE   RESUME
  407.  RUN       SHELL     TROFF     TRON      UNLOCK    VARPTR$
  408.  
  409.  
  410.  
  411.  DIM           (for $DYNAMIC arrays)
  412.  OPEN          (for RANDOM)
  413.  MOD or \ with LONG integers (only allowed with QBTINY3.LIB)
  414.  Floating point math
  415.  
  416.  
  417.  
  418. PDS:
  419.  
  420.  CVC       EVENT     MKC$      PRESERVE  STACK
  421.  
  422.  Far strings
  423.  Currency math
  424.  ISAM support
  425.  
  426.                       Crescent's P.D.Q.                 page 10
  427.  
  428.  
  429.  
  430. Many of you are probably familiar with Crescent Software's
  431. P.D.Q. library.  P.D.Q. is similar to QBTiny in that it is a
  432. replacement for the default support library.  P.D.Q. provides
  433. some powerful advantages which QBTiny does not have, including
  434. the ability to make TSRs and interrupt handlers.  Crescent also
  435. provides printed manuals, phone tech support, and support for
  436. BASCOM/PDS as well as QuickBasic.  P.D.Q. runs about $150.
  437. Crescent Software is available at the following:
  438.  
  439.    800-35-BASIC    orders only, voice line | 9:00-5:00 EST
  440.    203-438-5300    tech info, voice line   | (Connecticut)
  441.    203-426-5958    BBS, modem line         |
  442.  
  443.    Crescent Software, Inc.
  444.    11 Bailey Avenue
  445.    Ridgefield, CT 06877
  446.  
  447. As I write this, the best features of QBTiny are in the process
  448. of being merged into P.D.Q.  In addition, P.D.Q. is being
  449. updated to support Microsoft's new Visual Basic for DOS, which
  450. is incompatible with QBTiny.  Call Crescent for the latest
  451. details, and tell 'em Tom Hanlin sent you!
  452.  
  453.                         Which Runtime?                  page 11
  454.  
  455.  
  456.  
  457. It is possible for your program to automatically detect which
  458. of the three runtime libraries (default, P.D.Q., QBTiny) it is
  459. using.  Of course, the program is unlikely to compile if it
  460. uses a feature that isn't provided by the specified library.
  461. Still, since there are differences in the way each library
  462. handles specific routines, it may be helpful to know which one
  463. is being used.
  464.  
  465. The VAL function is implemented differently by each library.
  466. The P.D.Q. version stops when it encounters a space.  The
  467. QBTiny version does not mimic certain obscure bugs that are
  468. present in the default library.  The following program fragment
  469. makes use of these differences to identify which runtime
  470. library is in use:
  471.  
  472.    IF CINT(VAL("1 2")) = 1 THEN   ' P.D.Q. stops at spaces
  473.       PRINT "PDQ.LIB"
  474.    ELSEIF CINT(VAL("&H")) THEN    ' BCOM45 has a hex bug
  475.       PRINT "BCOM45.LIB"
  476.    ELSE                           ' otherwise, must be QBTiny
  477.       PRINT "QBTINY.LIB"
  478.    END IF
  479.  
  480.